import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:xbxxz_assistant/web/webview_page.dart';

class StrategyContainerPage extends StatefulWidget {
  var data;

  StrategyContainerPage({Key key, @required this.data}) : super(key: key);

  @override
  _StrategyContainerPageState createState() => _StrategyContainerPageState();
}

class _StrategyContainerPageState extends State<StrategyContainerPage> {
  final webviewPlugin = FlutterWebviewPlugin();

  @override
  void initState() {
    super.initState();
    webviewPlugin.close();
  }

  @override
  void dispose() {
    webviewPlugin.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Padding(
        padding: EdgeInsets.all(10.0),
        child: ListView.builder(
          itemCount: widget.data.length,
          itemBuilder: (context, index) {
            return GestureDetector(
              child: ListTile(
                leading: Image.network(
                  widget.data[index]["icon"],
                  width: 30.0,
                  height: 30.0,
                ),
                title: Text(widget.data[index]["title"]),
                trailing: Icon(Icons.chevron_right),
              ),
              onTapUp: (T) {
                Navigator.of(context)
                    .push(MaterialPageRoute(builder: (context) {
                  return WebViewPage(
                      widget.data[index]["url"], widget.data[index]["title"]);
                }));
              },
            );
          },
        ),
      ),
    );
  }
}
